Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hashring

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hashring

A consistent hashring compatible with ketama hashing and python's hash_ring

  • 3.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is hashring?

The hashring npm package is a consistent hashing library that allows for the distribution of keys across a set of nodes. It is useful for load balancing, distributed caching, and sharding data across multiple servers.

What are hashring's main functionalities?

Creating a Hash Ring

This feature allows you to create a hash ring with a set of nodes. The nodes can be any identifier, such as server names or IP addresses.

const HashRing = require('hashring');
const ring = new HashRing(['node1', 'node2', 'node3']);

Adding and Removing Nodes

This feature allows you to dynamically add or remove nodes from the hash ring. This is useful for scaling up or down the number of nodes in your system.

ring.add('node4');
ring.remove('node2');

Getting the Node for a Key

This feature allows you to get the node responsible for a given key. This is useful for determining which node should handle a particular piece of data.

const node = ring.get('myKey');

Weighting Nodes

This feature allows you to assign weights to nodes, so some nodes can handle more keys than others. This is useful for load balancing when some nodes have more capacity than others.

const weightedRing = new HashRing({'node1': 1, 'node2': 2, 'node3': 1});

Other packages similar to hashring

Keywords

FAQs

Package last updated on 21 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc